<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-07-09 14:07:16
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Models;

use App\Traits\MaterialTrait;
use App\Traits\SoftDeletesTrait;


class PurchaseApplyDetails extends BaseModel
    {
    use SoftDeletesTrait;
    use MaterialTrait;
    public $timestamps = true;
    public $table = "sys_purchase_apply_details";
    protected $guarded = [];
    protected $casts = [
        'auxiliary_quantity' => 'decimal:2',
        'quantity'           => 'decimal:2',
        'remain_quantity'    => 'decimal:2',
    ];


    public function company()
        {
        return $this->belongsTo(Company::class);
        }

    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'status_name');
            });
        }
    public function main()
        {
        return $this->belongsTo(PurchaseApply::class, "main_id");
        }
    }
